;input variables required; [l] [th] [sel_th] [dth] [pth] [dminth]
;outputs; [body]
;
;thread spiral
{Set:[zth]={Math:-[l]+[th]}}
_Spiral 0,0,[zth] 0,0,-[l]-([pth]*2) _Mode=_Pitch _Pitch [pth] 0,[dth]/2,[zth] 0,[dth]/2,-[l]-([pth]*2) _Enter
_SelLast
{Set:[spiral]={SelectedObjs}}	
_SelNone
;
;draw the thread section
{Set:[val]={Math:(([dth]-[dminth])/2)+([tol]*2)}}
{Set:[SectionID]={Guid}}
_Polyline _PersistentClose=_No 0,[dminth]/2,[zth] _Mode=_Line 0,[dminth]/2,[zth]+([pth]/8) 0,([dminth]/2)+[val],[zth]+([pth]/8)+(tan(30d)*[val]) 0,([dminth]/2)+[val],[zth]-([pth]/8)-(tan(30d)*[val]) 0,[dminth]/2,[zth]-([pth]/8) _Close
_SelLast
{Set:[section]={SelectedObjs}}
_Copy _InPlace
_SelNone
_SelLast
_Move 0,0,0 0,[pth]*0.6,0
-_Properties _Object _Name [SectionID] _Enter _Enter
_SelNone
_SelID [section]
_-Properties _Object _Name [SectionID] _Enter _Enter
_Move 0,0,0 0,0,-[pth]
_Copy _InPlace
_SelNone
_SelLast
{Set:[val]={Math:int(([zth]+[l])/[pth])+1}}
_Move 0,0,-[zth] {Math:[val]*[pth]} 0,0,-[l]
_SelNone
;
;create the surface and substract to the body
-_Sweep1 '_SelID [spiral] '-_SelName [SectionID] _Enter _Natural _Enter _Style=_Roadlike 0,0,[zth] 0,0,-[l] _Simplify=_None _Closed=_No _ShapeBlending=_Local _Enter
_SelLast
{Cap:[tol]}
{Set:[cut]={SelectedObjs}}
_SelNone
{BooleanDifference:[tol]:[body]:[cut]}
{Set:[body]={SelectedObjs}}
_SelNone
;
;delete the sweep curves
_SelID [spiral]
_Delete
-_SelName [SectionID]
_Delete